import request from '../utils/request'

export const registerUser = (userDTO) => {
	return request({
		url: '/users',
		method: 'POST',
		data: userDTO,
	})
}

export const deleteUser = (userId) => {
	return request({
		url: `/users/${userId}`,
		method: 'DELETE',
	})
}

export const updateUser = (userId, userDTO) => {
	return request({
		url: `/users/${userId}`,
		method: 'PUT',
		data: userDTO,
	})
}

export const partialUpdateUser = (userId, userDTO) => {
	return request({
		url: `/users/${userId}`,
		method: 'PATCH',
		data: userDTO,
	})
}

export const getUser = (account) => {
	return request({
		url: `/users/${account}`,
		method: 'GET',
	})
}
export const listClassNumbers = () => {
	return request({
		url: `/users/classNumbers`,
		method: 'GET',
	})
}

export const listUsers = (currentPage, pageSize) => {
	return request({
		url: `/users?currentPage=${currentPage}&pageSize=${pageSize}`,
		method: 'GET',
	})
}

export const listUsersFilterBy = (currentPage, pageSize, classNumber, role) => {
	return request({
		url: `/users?currentPage=${currentPage}&pageSize=${pageSize}&classNumbers=${classNumber}&roles=${role}`,
		method: 'GET',
	})
}

export const listUsersOrderByCredit = (currentPage, pageSize, field) => {
	return request({
		url: `/users?currentPage=${currentPage}&pageSize=${pageSize}&orderBy=${field}`,
		method: 'GET',
	})
}

export const listUsersOrderByLikeCount = (currentPage, pageSize) => {
	return request({
		url: `/users/like?offset=${currentPage}&limit=${pageSize}`,
		method: 'GET',
	})
}
